<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      xmlns:th="http://www.thymeleaf.org"
      layout:decorator="layout">
<head>
    <title th:inline="text">Edit &middot; [[${project.id}]]</title>
</head>
<body>
<div layout:fragment="header-container"></div>
  <div layout:fragment="content" class="container">
    <div class="main-body--wrapper">
      <div class="admin-index--title">
        <div class="content--title search-title" th:inline="text">
          <a th:href="@{/admin}">Admin</a> : <a th:href="@{/admin/projects}">Projects</a> : Edit [[${project.id}]]
        </div>
      </div>
      <form th:action="@{'/admin/projects/' + ${project.id}}" method="post" th:object="${project}">
          <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
          <label for="groupId">Group ID</label>
          <input type="text" name="groupId" id="groupId" th:value="${groupId}" value="org.springframework"/>
          <label for="id">ID</label>
          <input type="text" th:field="*{id}"/>
          <label for="groupId">Category</label>
          <select th:field="*{category}">
              <option th:each="c : ${categories}"
                      th:value="${c}"
                      th:text="${c}">incubator</option>
          </select>
          <label for="name">Name</label>
          <input type="text" th:field="*{name}"/>
          <label for="repoUrl">Repository URL</label>
          <input type="text" th:field="*{repoUrl}"/>
          <label for="siteUrl">Site URL</label>
          <input type="text" th:field="*{siteUrl}"/>
          <label for="stackOverflowTags">StackOverflow Tags (comma-separated list)</label>
          <input type="text" th:field="*{stackOverflowTags}"/>
          <label for="siteUrl">Aggregator</label>
          <input type="checkbox" th:field="*{aggregator}" value="true"/>
          <fieldset>
              <legend>Releases</legend>
              <table class="table table-striped">
                  <thead>
                    <tr>
                        <td>Delete?</td>
                        <td>Artifact ID</td>
                        <td>Version</td>
                        <td>Current</td>
                        <td>Reference URL</td>
                        <td>API URL</td>
                    </tr>
                  </thead>
                  <tbody>
                      <tr th:each="release,releaseStat : ${project.projectReleases}">
                          <td><input type="checkbox" name="releasesToDelete" th:value="*{projectReleases[__${releaseStat.index}__].version}"></td>
                          <td><input type="text" th:field="*{projectReleases[__${releaseStat.index}__].artifactId}" /></td>
                          <td><input type="text" th:field="*{projectReleases[__${releaseStat.index}__].version}" /></td>
                          <td><input type="checkbox" th:field="*{projectReleases[__${releaseStat.index}__].current}" value="true"/></td>
                          <td><input type="text" th:field="*{projectReleases[__${releaseStat.index}__].refDocUrl}" /></td>
                          <td><input type="text" th:field="*{projectReleases[__${releaseStat.index}__].apiDocUrl}" /></td>
                      </tr>
                      <tr th:with="size=${project.projectReleases.size()}">
                          <td></td>
                          <td><input type="text" th:field="*{projectReleases[__${size}__].artifactId}" /></td>
                          <td><input type="text" th:field="*{projectReleases[__${size}__].version}" /></td>
                          <td><input type="checkbox" th:field="*{projectReleases[__${size}__].current}" value="true"/></td>
                          <td><input type="text" th:field="*{projectReleases[__${size}__].refDocUrl}" /></td>
                          <td><input type="text" th:field="*{projectReleases[__${size}__].apiDocUrl}" /></td>
                      </tr>
                  </tbody>
              </table>
          </fieldset>
          <input type="submit" value="Save"/>
      </form>
    </div>
</div>
</body>
</html>
